package action;

import Impl.TopicDaoImpl;
import Impl.plateDaoImpl;
import entity.Plate;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "ShowBlockListAction")
public class ShowBlockListAction extends HttpServlet {
    plateDaoImpl plateDao = new plateDaoImpl();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("---------正在执行showblockAction-----------");
        ArrayList<Plate> sectionInfoList;
        ArrayList<Plate> rootSectionInfoList;
        ArrayList<Plate> childSectionInfoList;
        sectionInfoList = (ArrayList<Plate>) plateDao.findPlateByPId(0);
        rootSectionInfoList = (ArrayList<Plate>) plateDao.findAllPlate();
        childSectionInfoList = plateDao.findAllChildPlate();
        request.getSession().setAttribute("sectionInfoList", sectionInfoList);
        request.getSession().setAttribute("rootSectionInfoList", rootSectionInfoList);
        request.getSession().setAttribute("childSectionInfoList", childSectionInfoList);
        request.getRequestDispatcher("/user/user_index.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
